package com.study.mallcoupon.controller;


import com.study.mallcoupon.entity.SmsCoupon;
import com.study.mallcoupon.service.SmsCouponService;
import com.stydy.mallcommon.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 优惠券信息 前端控制器
 * </p>
 *
 * @author admin
 * @since 2022-03-05
 */
@RefreshScope//在nacos配置中心动态刷新配置
@RestController
@RequestMapping("coupon")
public class SmsCouponController {
    @Autowired
    private SmsCouponService smsCouponService;
    @Value("${user.name}")
     private String name;

    @Value("${user.age}")
    private Integer age;
    @RequestMapping("/memberCoupon")
    public R memberCoupon(){
        SmsCoupon smsCoupon = new SmsCoupon();
        smsCoupon.setCouponName("满100-10元");
        return R.ok().put("coupon", Arrays.asList(smsCoupon));
    }
    @GetMapping("/list")
    public R test(){
        List<SmsCoupon> list = this.smsCouponService.list();
        return R.ok().put("1",list);
    }

    @GetMapping("/peizhi")
    public R test1(){
        return R.ok().put("name",name).put("age",age);
    }
}

